export const mixinsModuleCss = {
  data() {
    return {};
  },
  mounted: function() {
    console.log("混入对象的钩子被调用");
  },
  computed: {
    // 混入模块样式
    moduleCss() {
      let style = JSON.parse(JSON.stringify(this.propsData.moduleCss));
      if (style.margin) style.margin = `0 0 ${style.margin}px 0`;
      if (style.padding) style.padding = `0 ${style.padding}px`;
      if (style.borderRadius) style["borderRadius"] = `${style.borderRadius}px`;

      if (!style.useBackground) {
        style["background"] = "inherit";
        style["backgroundColor"] = "inherit";
      }
      if (style?.bgImg && style?.bgOpacity) {
        style["backgroundColor"] = "inherit";
      }

      let obj = {
        margin: style.margin,
        backgroundColor: style.backgroundColor,
        borderRadius: style.borderRadius,
        padding: style.padding,
      };
      return obj;
    },
    outModuleCss() {
      let style = JSON.parse(JSON.stringify(this.propsData.moduleCss));
      if (style.margin) style.margin = `0 0 ${style.margin}px 0`;
      if (style.padding) style.padding = `0 ${style.padding}px`;
      if (style.borderRadius) style["borderRadius"] = `${style.borderRadius}px`;
      let obj = {
        margin: style.margin,
        borderRadius: style.borderRadius,
        padding: style.padding,
        position: "relative",
        overflow: "hidden",
      };
      return obj;
    },
    // 混入模块背景设置
    moduleBgCss() {
      let style = JSON.parse(JSON.stringify(this.propsData.moduleCss));

      if (style.borderRadius) style["borderRadius"] = `${style.borderRadius}px`;
      if (!style.useBackground) {
        return {
          background: "inherit",
        };
      }
      let hSpace = style.padding;
      if (hSpace) {
        style["width"] = `calc(100% - ${hSpace * 2}px)`;
        style["left"] = hSpace + "px";
      }
      return style;
    },
  },
  methods: {},
};
